/**
 * VMware Continuent Tungsten Replicator
 * Copyright (C) 2015 VMware, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *      
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Initial developer(s): Robert Hodges
 * Contributor(s): 
 */

package com.continuent.tungsten.common.network;

/**
 * Contains status information from a single ping method invocation.
 * 
 * @author <a href="mailto:robert.hodges@continuent.com">Robert Hodges</a>
 */
public class PingNotification
{
    private String    hostName;
    private boolean   reachable;
    private String    methodName;
    private long      timeout;
    private long      duration;
    private String    notes;
    private Throwable exception;

    /** Returns the host for which this ping notification used. */
    public String getHostName()
    {
        return hostName;
    }

    public void setHostName(String hostName)
    {
        this.hostName = hostName;
    }

    /** Returns true if the method determined the host was reachable. */
    public boolean isReachable()
    {
        return reachable;
    }

    public void setReachable(boolean reachable)
    {
        this.reachable = reachable;
    }

    /** Returns the ping method used. */
    public String getMethodName()
    {
        return methodName;
    }

    public void setMethodName(String methodName)
    {
        this.methodName = methodName;
    }

    /** Returns the ping timeout in milliseconds. */
    public long getTimeout()
    {
        return timeout;
    }

    public void setTimeout(long timeout)
    {
        this.timeout = timeout;
    }

    /** Returns actual ping duration in milliseconds. */
    public long getDuration()
    {
        return duration;
    }

    public void setDuration(long duration)
    {
        this.duration = duration;
    }

    /**
     * Returns a comment string generated by the ping method to provide audit
     * tracking about what was done. These should be available regardless of
     * whether there is an exception or not.
     */
    public String getNotes()
    {
        return notes;
    }

    public void setNotes(String notes)
    {
        this.notes = notes;
    }

    /**
     * Returns an exception generated by the ping method, if any. Exceptions are
     * only generated if there is a failure of the ping method itself.
     */
    public Throwable getException()
    {
        return exception;
    }

    public void setException(Throwable exception)
    {
        this.exception = exception;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        StringBuffer sb = new StringBuffer("Ping notification:");
        sb.append(" host=" + hostName);
        sb.append(" reachable=").append(reachable);
        sb.append(" method=").append(methodName);
        sb.append(" timeout=").append(timeout);
        sb.append(" duration=").append(duration);
        sb.append(" notes=").append(notes);
        sb.append(" throwable=").append(exception);
        return sb.toString();
    }
}